package tech.zjp.ssm.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.core.convert.converter.Converter;

/**
*
* @Description: 
* @Author: 周军鹏
* @Date: 2020年3月4日 下午3:03:09
*/
public class StringToDateConverter implements Converter<String, Date> {
	private String pattern;
	public StringToDateConverter(String pattern){
		this.pattern = pattern;		
	}
	@Override
	public Date convert(String s) {
		Date date = null;
		try {
			date =  new SimpleDateFormat(pattern).parse(s);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
}
